package com.letv.whatslive.model.convert;

import com.letv.whatslive.common.utils.ObjectUtils;
import com.letv.whatslive.model.PictureCompressHistory;
import com.letv.whatslive.model.utils.ObjUtils;
import com.mongodb.BasicDBObject;
import com.mongodb.DBObject;

/**
 * Created by haojiayao on 16-3-16.
 */
public class PictureCompressHistoryConvert {

    public static DBObject castPictureCompressHistoryToDBObject(PictureCompressHistory picCompressHistory) {

        DBObject dbo = new BasicDBObject();

        dbo.put("userId", ObjUtils.toLong(picCompressHistory.getUserId()));
        dbo.put("programId", ObjUtils.toLong(picCompressHistory.getProgramId()));
        dbo.put("createTime", ObjUtils.toString(picCompressHistory.getCreateTime()));

        return dbo;
    }

    public static PictureCompressHistory castDBObjectToPictureCompressHistory(DBObject dbObject){

        if(dbObject != null) {
            PictureCompressHistory pictureCompressHistory = new PictureCompressHistory();
            pictureCompressHistory.setId(ObjectUtils.toLong(dbObject.get("_id")));
            pictureCompressHistory.setCreateTime(ObjectUtils.toString(dbObject.get("createTime")));
            pictureCompressHistory.setUserId(ObjUtils.toLong(dbObject.get("userId")));
            pictureCompressHistory.setProgramId(ObjUtils.toLong(dbObject.get("programId")));
            return pictureCompressHistory;
        }else{
            return null;
        }
    }




}
